//
// Created by aaa on 2025/7/14.
//

#include<bits/stdc++.h>

using namespace std;
const int N = 1e3 + 10;

int n,m;
int w[N],v[N],dp[N][N];

//求具体方案
//4 5
//1 2
//2 4
//3 4
//4 6
int main(){
    cin >> n >> m;
    for(int i = 1;i <= n;i++) cin >> w[i] >> v[i];

    for(int i = n;i >= 1;i--){
        for(int j = 0;j <= m;j++){
            dp[i][j] = dp[i + 1][j];
            if(j >= w[i]){
                dp[i][j] = max(dp[i][j],dp[i + 1][j - w[i]] + v[i]);
            }
        }
    }

    int j = m;
    for(int i = 1;i <= n;i++){
        if(j >= w[i] && dp[i][j] == dp[i + 1][j - w[i]] + v[i]){
            cout << i << " ";
            j -= w[i];
        }
    }

    return 0;
}